package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zbpx {
   private HashMap b;
   zayy[] a;
   private zakl c;
   private int d = 0;

   HashMap a() {
      return this.b;
   }

   zbpx() {
      this.d = 0;
      this.b = new HashMap();
      this.a = new zayy[16];
      this.c = new zakl();
   }

   boolean b() {
      if (this.d < 1) {
         return false;
      } else if (this.c.a() > 1) {
         return true;
      } else {
         if (this.c.a() == 1) {
            int var1 = this.c.b(0);
            if (var1 < this.d) {
               return true;
            }

            ++var1;

            while(var1 < this.a.length) {
               if (this.a[var1] != null) {
                  return true;
               }

               ++var1;
            }
         }

         for(int var2 = 0; var2 < this.a.length; ++var2) {
            zayy var3 = this.a[var2];
            if (var3 == null) {
               return var2 < this.d;
            }

            if (var3.f() && !((zbap)var3).j()) {
               return true;
            }
         }

         return false;
      }
   }

   int a(int[] var1, int[] var2) {
      this.d = 0;
      this.c.c();
      int var3 = 0;
      int var5 = 0;

      zayy var4;
      int var6;
      for(var6 = 0; var6 < var1.length; ++var6) {
         var4 = this.a[var6];
         if (var1[var6] > 0) {
            ++this.d;
            var4.d = var1[var6];
            if (var6 != var3) {
               var5 += var4.d;
               var2[var6] = var3;
               var4.e = var3;
               this.a[var3] = var4;
               this.a[var6] = null;
            } else {
               var2[var6] = var6;
            }

            ++var3;
         } else if (var4 != null) {
            if (var4.e()) {
               this.b.remove(var4.c);
            }

            this.a[var6] = null;
         }
      }

      if (this.a.length > var1.length) {
         for(var6 = var1.length; var6 < this.a.length; ++var6) {
            var4 = this.a[var6];
            if (var4 != null) {
               if (var6 != var3) {
                  var5 += var4.d;
               }

               ++this.d;
               var2[var6] = var3;
               var4.e = var3;
               this.a[var3] = var4;
               this.a[var6] = null;
               ++var3;
            }
         }
      }

      return var5;
   }

   long c() {
      long var1 = 0L;

      for(int var3 = 0; var3 < this.a.length; ++var3) {
         if (this.a[var3] != null) {
            var1 = (var1 & 4294967295L) + ((long)this.a[var3].d & 4294967295L);
         }
      }

      return var1;
   }

   int d() {
      return this.d;
   }

   private void d(int var1) {
      if (this.d + var1 >= this.a.length) {
         zayy[] var2 = new zayy[this.a.length * 2];

         for(int var3 = 0; var3 < this.a.length; ++var3) {
            var2[var3] = this.a[var3];
         }

         this.a = var2;
      }

   }

   zayy a(int var1) {
      ++this.a[var1].d;
      return this.a[var1];
   }

   zayy b(int var1) {
      return this.a[var1];
   }

   void a(zayy var1, int var2) {
      if (this.a[var2] != null) {
         ++this.a[var2].d;
      } else {
         this.d(1);
         this.b.put(var1.c, var1);
         this.a[var2] = var1;
         var1.e = var2;
         ++this.d;
      }

   }

   void a(String var1, int var2, byte[] var3, Object var4) {
      this.d(1);
      if (var4 != null) {
         zatv var5 = new zatv(var1, var3, var4);
         this.a[var2] = var5;
         var5.e = var2;
         ++this.d;
      } else if (var3 != null) {
         zbap var6 = new zbap(var1, var3, 0);
         this.a[var2] = var6;
         var6.e = var2;
         ++this.d;
      } else {
         zayy var7 = new zayy(var1, 0);
         this.a(var7, var2);
      }

   }

   void b(zayy var1, int var2) {
      if (var1.e()) {
         if (this.a[var2] != null) {
            ++this.a[var2].d;
         } else {
            this.d(1);
            this.b.put(var1.c, var1);
            this.a[var2] = var1;
            var1.e = var2;
            ++this.d;
         }
      } else {
         this.d(1);
         this.a[var2] = var1;
         var1.e = var2;
         ++this.d;
      }

   }

   void a(zayy var1) {
      ++var1.d;
      if (var1.e()) {
         this.b.put(var1.c, var1);
      }

      if (this.c.a() != 0) {
         int var2 = this.c.b();
         this.a[var2] = var1;
         var1.e = var2;
      } else if (this.d < this.a.length) {
         this.a[this.d] = var1;
         var1.e = this.d;
      } else {
         this.d(1);
         this.a[this.d] = var1;
         var1.e = this.d;
      }

      ++this.d;
   }

   zayy a(String var1) {
      zayy var2 = (zayy)this.b.get(var1);
      if (var2 != null) {
         ++var2.d;
      } else {
         var2 = new zayy(var1, 0);
         this.a(var2);
      }

      return var2;
   }

   void c(int var1) {
      zayy var2 = this.a[var1];
      --var2.d;
      if (var2.d <= 0) {
         int var3 = var2.e;
         this.a[var3] = null;
         this.c.a(var3);
         if (var2.e()) {
            this.b.remove(var2.c);
         }

         --this.d;
      }

   }

   void b(zayy var1) {
      --var1.d;
      if (var1.d <= 0) {
         this.a[var1.e] = null;
         if (var1.e()) {
            this.b.remove(var1.c);
         }

         --this.d;
         this.c.a(var1.e);
      }

   }

   void e() {
   }

   void a(zbap var1) {
      if (this.c.a() == 0) {
         this.d(1);
         this.a[this.d] = var1;
         var1.e = this.d++;
      } else {
         int var2 = this.c.b();
         this.a[var2] = var1;
         var1.e = var2;
         ++this.d;
      }

   }

   zayy a(String var1, byte[] var2) {
      zayy var3 = null;

      int var4;
      for(var4 = 0; var4 < this.a.length; ++var4) {
         var3 = this.a[var4];
         if (var3 != null && !var3.g() && var3.f() && ((zbap)var3).a(var1, var2)) {
            ++var3.d;
            return var3;
         }
      }

      zbap var5 = new zbap(var1, var2, 1);
      if (this.c.a() == 0) {
         this.d(1);
         this.a[this.d] = var5;
         var5.e = this.d++;
      } else {
         var4 = this.c.b();
         this.a[var4] = var5;
         var5.e = var4;
         ++this.d;
      }

      return var5;
   }

   zayy a(zbap var1, int var2, WorksheetCollection var3) {
      zbar.a(var1.i(), var1.c.length(), var3.k(var2), false);
      FontSetting[] var4 = new FontSetting[var1.i().size()];

      for(int var5 = 0; var5 < var4.length; ++var5) {
         var4[var5] = (FontSetting)var1.i().get(var5);
      }

      String var11 = var1.c;
      int var6 = var1.e;
      byte[] var7 = zbar.a(var2, var11, var4, var3);
      if (var7 == null) {
         this.c.a(var6);
         this.a[var6] = null;
         --this.d;
         return this.a(var11);
      } else {
         for(int var9 = 0; var9 < var6; ++var9) {
            zayy var8 = this.a[var9];
            if (var8 != null && var8.f()) {
               zbap var10 = (zbap)var8;
               if (var10.a(var11, var7)) {
                  ++var8.d;
                  this.c.a(var6);
                  this.a[var6] = null;
                  --this.d;
                  return var10;
               }
            }
         }

         var1.a(var7);
         var1.a((ArrayList)null);
         return var1;
      }
   }

   String[] f() {
      com.aspose.cells.b.a.a.zd var1 = new com.aspose.cells.b.a.a.zd();

      for(int var2 = 0; var2 < this.a.length; ++var2) {
         if (this.a[var2] != null && this.a[var2].c.startsWith("&=")) {
            var1.b(this.a[var2].c, true);
         }
      }

      String[] var3 = new String[var1.b()];
      com.aspose.cells.a.e.ze.a((Iterable)var1.c(), (String[])var3, 0);
      return var3;
   }
}
